/*
 * @Author: hrg
 * @Date: 2024-01-27 08:54:43
 * @LastEditTime: 2024-01-27 10:36:13
 * @FilePath: \study_go\study06_gin\gin_demo08\server\main.go
 * @Description:路由组：routes group
 */

package main

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.New()

	v1 := r.Group("/v1")

	{
		v1.GET("/login", login)
		v1.GET("submit", submit)
	}
	v2 := r.Group("/v2")

	{
		v2.GET("login", login)
		v2.GET("submit", submit)
	}

	r.Run(":9090")
}

func login(c *gin.Context) {
	name := c.DefaultQuery("name", "jack")
	c.String(200, fmt.Sprintf("hello  %v", name))
}

func submit(c *gin.Context) {
	name := c.DefaultQuery("name", "lili")
	c.String(200, fmt.Sprintf("hello  %v", name))
}
